<?php

namespace app\admin\controller\member;

use app\admin\model\UM as UM;
use app\admin\service\MemberInvitedStatisticsService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * MemberInvitedStatistics 控制器
 * Class MemberInvitedStatistics
 * @package app\admin\controller\member;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 */
class MemberInvitedStatistics
{
    // 请求参数
    private Request $request;

    // service
    private MemberInvitedStatisticsService $service;

    public function __construct(Request $request, MemberInvitedStatisticsService $memberInvitedStatisticsService)
    {
        $this->request = $request;
        $this->service = $memberInvitedStatisticsService;
    }


    /**
     * 详情
     * @param UM|null $user
     * @return ApiResponse
     * @url /member/member_invited_statistics/read
     */
    public function read(?UM $user): ApiResponse
    {
        $request = $this->request;

        $inviteId = $request->param('inviteId', null);
        $channel = $request->param('channel', null);
        $provinceId = $request->param('provinceId', null);
        $cityId = $request->param('cityId', null);
        $startTime = $request->param('startTime', null);
        $endTime = $request->param('endTime', null);
        $kw = $request->param('kw', null);

        return ApiResponse::success($this->service->read($user, $channel, $provinceId, $cityId, $startTime, $endTime, $kw, $inviteId));
    }

}
